//3. 在行列相等数组计算主对角线元素的和
#include<stdio.h>
#define N 3
#define M 3
int main()
{
	int i,j,sum = 0;
	int a[N][M] = {{2,5,9},{3,5,7},{4,6,10}};		
	for(i = 0; i < N; i++)
		for(j = 0; j < M; j++)
		{
			if(i == j)
				sum += a[i][j];
		}
	printf("主对角线之和为：%d\n",sum);
	return 0;
}
